<template>
  <el-table :data="list" border style="width: 100%">
    <el-table-column fixed prop="number" label="试题编号" width="150">
    </el-table-column>
    <el-table-column prop="subjectID" label="学科" width="60">
      <template slot-scope="{ row }">
        <span v-if="row.subjectID === 1">Java</span>
        <span v-if="row.subjectID === 4">前端</span>
      </template>
    </el-table-column>
    <el-table-column prop="catalog" label="目录" width="120"> 
      <!-- <template slot-scope="{ row }">
        <span v-if="row.catalogID === 5">css基础</span>
        <span v-if="row.catalogID === 2">javaWEB</span>
        <span v-if="row.catalogID === 1">java基础</span>
      </template> -->
    </el-table-column>
    <el-table-column prop="questionType" label="题型" width="100">
      <template slot-scope="{ row }">
        <span v-if="row.questionType === '1'">单选</span>
        <span v-if="row.questionType === '2'">多选</span>
        <span v-if="row.questionType === '3'">简答</span>
      </template>
    </el-table-column>
    <el-table-column prop="question" label="题干" width="100">
      <template slot-scope="{ row }">
        <span v-html="row.question">单选</span>
      </template>
    </el-table-column>
    <el-table-column prop="addDate" label="录入时间" width="120">
    </el-table-column>
    <el-table-column prop="difficulty" label="难度" width="80">
      <template slot-scope="{ row }">
        <span v-if="row.difficulty === '1'">简单</span>
        <span v-if="row.difficulty === '2'">一般</span>
        <span v-if="row.difficulty === '3'">困难</span>
      </template>
    </el-table-column>
    <el-table-column prop="creator" label="录入人" width="120" value>
    </el-table-column>

    <el-table-column label="操作" width="200">
      <template slot-scope="{ row }">
        <el-button
          circle
          plain
          size="small"
          type="primary"
          icon="el-icon-view"
        ></el-button>
        <el-button
          circle
          plain
          size="small"
          type="success"
          icon="el-icon-edit"
        ></el-button>
        <!-- 1 删除按钮绑定事件 【删除功能】 -->
        <el-button
          @click="deletebtn(row.id)"
          circle
          plain
          size="small"
          type="danger"
          icon="el-icon-delete"
        ></el-button>
        <el-button
        @click="Collection(row.id)"
          circle
          size="small"
          type="warning"
          plain
          icon="el-icon-star-off"
        ></el-button>
      </template>
    </el-table-column>
  </el-table>

  <!-- <div>1111</div> -->
</template>

<script>
import {
  deleteApi,
  selectedApi
} from "@/api/list";
export default {
  name: "ChoicePage",
  props: {
    list: {
      type: Array,
    },
  },

  data() {
    return {};
  },
  methods: {

    // 删除
    async deletebtn(id) {
      await this.$confirm('此操作将永久删除该文件, 是否继续?', '提示');
      await deleteApi(id);
      this.$message.success("删除成功");
      if (this.qureyData.page > 1 && this.list.length === 1) {
        this.qureyData.page--;
      }
      // 页面刷新
      this.$emit('updateList');
    },
    // 精选题库上下架
    async Collection(id){
      console.log(id);
      console.log(this.list);
       await this.$confirm("此操作将该题目加入精选，是否继续？", '提示');
      await selectedApi(id);
      this.$message.success("加入成功");
      if (this.qureyData.page > 1 && this.list.length === 1) {
        this.qureyData.page--;
      }
      // 页面刷新
      this.$emit('updateList');
    }
  },
};
</script>

<style>
</style>